'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { STRING, INTEGER, DATE, UUIDV4, UUID } = Sequelize;
    await queryInterface.createTable('books', {
      name: STRING(64),
      counts: INTEGER(5),
      last_couonts: INTEGER(5),
      intro: STRING(128),
      created_at: DATE,
      updated_at: DATE,
      uuid: { type: UUID, defaultValue: UUIDV4, primaryKey: true },
      user_uuid: {
        type: UUID,
        references: {
          model: 'users',
          key: 'uuid',
        },
        onUpdate: 'cascade',
        onDelete: 'cascade',
      },
    });
  },

  down: async queryInterface => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('books');
  },
};
